home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Format 1994 October
/
Macformat17.cdr
/
Shareware City
/
Developers
/
shutdown-fx-201-c
/
sfx ƒ
/
sfx control app ƒ
/
sfx code ƒ
/
sfx gestalt.c
< prev
next >
Wrap
Text File
|
1994-07-11
|
4KB
|
143 lines
/**********************************************************************\
File: sfx gestalt.c
Purpose: This module handles our gestalt selector function for
setting & getting the addresses of our fade procedure,
shutdown proc, and restart proc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program in a file named "GNU General Public License".
If not, write to the Free Software Foundation, 675 Mass Ave,
Cambridge, MA 02139, USA.
\**********************************************************************/
#include "GestaltEQU.h"
#include "sfx gestalt equ.h"
#include "sfx gestalt.h"
#include "util.h"
enum ErrorTypes MakeNewGestaltSelectors(void)
{
Handle theProcHandle;
Ptr theGestaltFunction;
unsigned long theSize;
OSErr gestaltError;
theProcHandle=Get1Resource('PROC', 11); /* get gestalt selector function */
if ((ResError()!=noErr) || (theProcHandle==0L))
return kCantGetProc11Resource;
if (*theProcHandle==0L)
LoadResource(theProcHandle);
if (*theProcHandle==0L)
return kCantGetProc11Resource;
theProcHandle=StripAddress(theProcHandle);
*theProcHandle=StripAddress(*theProcHandle);
theGestaltFunction=NewPtrSys(theSize=GetHandleSize(theProcHandle));
if (theGestaltFunction==0L)
return kNoMemoryInSystemHeap;
theGestaltFunction=StripAddress(theGestaltFunction);
Mymemcpy(theGestaltFunction, *theProcHandle, theSize);
ReleaseResource(theProcHandle);
theProcHandle=0L;
gestaltError=NewGestalt(sfxGetVersion, theGestaltFunction);
if (gestaltError!=noErr)
return kCantMakeNewGestalt;
gestaltError=NewGestalt(sfxGetFadeProcPtr, theGestaltFunction);
if (gestaltError!=noErr)
return kCantMakeNewGestalt;
gestaltError=NewGestalt(sfxGetShutdownProcPtr, theGestaltFunction);
if (gestaltError!=noErr)
return kCantMakeNewGestalt;
gestaltError=NewGestalt(sfxGetRestartProcPtr, theGestaltFunction);
if (gestaltError!=noErr)
return kCantMakeNewGestalt;
gestaltError=NewGestalt(sfxGetFadeProcPtrAddress, theGestaltFunction);
if (gestaltError!=noErr)
return kCantMakeNewGestalt;
gestaltError=NewGestalt(sfxGetShutdownProcPtrAddress, theGestaltFunction);
if (gestaltError!=noErr)
return kCantMakeNewGestalt;
gestaltError=NewGestalt(sfxGetRestartProcPtrAddress, theGestaltFunction);
if (gestaltError!=noErr)
return kCantMakeNewGestalt;
return allsWell;
}
enum ErrorTypes SetGestaltProcPtrs(ProcPtr fadeProcPtr, ProcPtr shutdownProcPtr,
ProcPtr restartProcPtr)
{
OSErr gestaltError;
long theAddress;
gestaltError=Gestalt(sfxGetFadeProcPtrAddress, &theAddress);
if (gestaltError!=noErr)
return kGestaltImproperlyInstalled;
*((ProcPtr*)theAddress)=fadeProcPtr;
gestaltError=Gestalt(sfxGetShutdownProcPtrAddress, &theAddress);
if (gestaltError!=noErr)
return kGestaltImproperlyInstalled;
*((ProcPtr*)theAddress)=shutdownProcPtr;
gestaltError=Gestalt(sfxGetRestartProcPtrAddress, &theAddress);
if (gestaltError!=noErr)
return kGestaltImproperlyInstalled;
*((ProcPtr*)theAddress)=restartProcPtr;
return allsWell;
}
enum ErrorTypes GetGestaltProcPtrs(ProcPtr *fadeProcPtr, ProcPtr *shutdownProcPtr,
ProcPtr *restartProcPtr)
{
OSErr gestaltError;
gestaltError=Gestalt(sfxGetFadeProcPtr, fadeProcPtr);
if (gestaltError!=noErr)
return kGestaltImproperlyInstalled;
gestaltError=Gestalt(sfxGetShutdownProcPtr, shutdownProcPtr);
if (gestaltError!=noErr)
return kGestaltImproperlyInstalled;
gestaltError=Gestalt(sfxGetRestartProcPtr, restartProcPtr);
if (gestaltError!=noErr)
return kGestaltImproperlyInstalled;
return allsWell;
}
Boolean sfxGestaltFunctionInstalledQQ(void)
{
long theVersion;
OSErr gestaltError;
gestaltError=Gestalt(sfxGetVersion, &theVersion);
return ((gestaltError==noErr) && (theVersion==1L));
}